var vm_deptdetail = new Vue({
    el: "#deptdetail",
    data: {
        deptid: $("#deptid").val(),		// 单位ID
        jigoujibie: $("#jigoujibie").val(),		// 机构类别

        deptlist: [],// 单位列表
        dept: {},//查看单位

        //查询用字段
        jigoumingcheng: '',
        diqu:''

    },
    created: function () {
        var _this = this;
        _this.bindDeptList();
        $.ajaxSettings.async = false;
    },


    methods: {

        // 根据单位ID查询下级单位
        bindDeptList: function () {
            var _this = this;

            var dept_layer = layer.open({type: 3});
            $.post('/system/deptdetail/customlist', {
                parentid: _this.deptid,
                jigoumingcheng: _this.jigoumingcheng,
                beizhu1:_this.diqu,
                rdm: Math.random()
            }, function (ppData) {
                layer.close(dept_layer);
                if (ppData != null) {
                    var data = ppData;
                    _this.deptlist = data;
                }
            }, "json");
        },

        toChakan: function (ppDeptId) {
            $("#myModalLabel1").html("单位信息");
            $("#modal-dialog1").attr("style", "width:1200px;");
            $("#deptModal1").modal();
            this.dept = {};
            this.bindDept(ppDeptId);
        },

        bindDept: function (deptid) {
            var _this = this;

            var dept_layer = layer.open({type: 3});
            $.post('/system/deptdetail/findone', {
                deptid: deptid,
                rdm: Math.random()
            }, function (ppData) {
                layer.close(dept_layer);

                if (ppData != null) {

                    if (ppData.result == "1") {
                        var data = ppData.resultContent;
                        _this.dept = data;
                    } else {
                        layer.alert(ppData.message);
                    }
                }
            }, "json");
        },

        reset: function () {
            var _this = this;

            _this.jigoumingcheng=""
            _this.diqu=""
            _this.bindDeptList();
        },
        toXiaji:function (deptitem) {
            $.modal.openTab("下级单位","/system/deptdetail/modaldept?deptid="+deptitem.id+"&jigoujibie="+deptitem.jigoujibie);
        }
    }

})
